package com.example.myservice;

import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.util.Log;

public class MyConn implements ServiceConnection {
    public MybindService.MyBinder myBinder;
    // 当成功绑定服务时调用的方法,该方法获取MyService中的Ibinder对象
    MyConn(MybindService.MyBinder binder){
        this.myBinder = binder;
    }
    @Override
    public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
        myBinder = (MybindService.MyBinder) iBinder;
        Log.i("life", "服务成功绑定, 内存地址为:" + myBinder.toString());
    } //当服务失去连接时调用的方法

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        // service被破坏或被杀死的时候调用
        Log.i("life", "服务成功解绑");
    }
}
